<template>
  <div class="login">
    <el-form label-width="80px">
      <el-form-item label="账号" style="padding-bottom: 5px;">
        <el-input placeholder="请输入账号" v-model="login.user"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input placeholder="请输入密码" v-model="login.pass" show-password></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
/* import {
  initlogin2
} from '@/api/mian.js' */
export default {
  data () {
    return {
      login: {
        user: '18201288771',
        pass: '111111'
      }

    }
  },
  methods: {
    onSubmit () {
      location.href = './home'
      // 最简单的一个验证
      /*  if (this.login.user === '') {
        this.$message.error('请输入账号')
      } else if (this.login.pass === '') {
        this.$message.error('请输入密码')
      } else {
        initlogin2({
          phone: this.login.user,
          password: this.login.pass
        })
          .then(res => {
            console.log(res)
            if (res.data.message === 'success') {
              // 将token保存在localstorge中
              localStorage.token = res.data.content
              // 将token保存在vuex中
              this.$store.commit('setUser', res.data.content)
              location.href = './home'
            } else {
              this.$message.error(res.data.message)
            }
            // console.log(res.data.success);
          }, () => {
            this.$message.error('登录失败')
          })
      } */
    }

  }
}
</script>

<style lang='scss' scoped>
  .login {
    /*  容器撑满高度 */
    height: 100vh;
    display: flex;
    /*  内容水平垂直居中 */
    align-items: center;
    justify-content: center;
    background-color: #e9eef3;

    .el-form {
      background-color: #fff;
      width: 300px;
      padding: 20px;
      border-radius: 10px;

      .el-button {
        width: 100%;
      }
    }
  }
</style>
